Skip to content

refactor(init): reuse resolveOrCreateTeam for wizard team resolution#679

Merged
betegon merged 2 commits intomainfrom
refactor/init-reuse-resolve-team
Apr 7, 2026
Merged

refactor(init): reuse resolveOrCreateTeam for wizard team resolution#679
betegon merged 2 commits intomainfrom
refactor/init-reuse-resolve-team

Conversation

@betegon
Copy link
Copy Markdown
Member

@betegon betegon commented Apr 7, 2026

Summary

The init wizard had ~55 lines of inline team resolution that duplicated resolveOrCreateTeam from resolve-team.ts. Both implementations did the same thing: list teams → 0 teams (auto-create) → 1 team (auto-select) → N teams (filter by membership → pick).

Adds an onAmbiguous callback to ResolveTeamOptions so the wizard can present a clack select() prompt when multiple teams match, instead of the shared function throwing ContextError.

Also fixes a silent error-swallowing catch (captureException + continue) that let team resolution failures pass through unnoticed — the wizard would continue without a team and fail later when project creation needed one.

Changes

  • resolve-team.ts: Added optional onAmbiguous callback to ResolveTeamOptions. When provided, it's called with the candidate teams instead of throwing ContextError. Non-breaking — existing callers are unaffected.
  • wizard-runner.ts: Replaced inline team resolution with a call to resolveOrCreateTeam. Errors now surface properly instead of being silently swallowed. Removed unused imports (createTeam, listTeams, getSentryBaseUrl).

Test plan

  • npx tsc --noEmit passes
  • npx biome check passes on changed files
  • Run sentry init against an org with 0, 1, and multiple teams
  • Run sentry init --yes against an org with multiple teams (should auto-pick first)
  • Cancel team selection mid-prompt — should exit cleanly with code 0

The init wizard had ~55 lines of inline team resolution that duplicated
the shared resolveOrCreateTeam logic. Both did: list teams → 0 (create)
→ 1 (auto-select) → N (filter by membership → pick).

Adds an onAmbiguous callback to resolveOrCreateTeam so the wizard can
present a clack select() prompt when multiple teams match, instead of
throwing ContextError.

Also fixes a silent error-swallowing catch that let team resolution
failures pass through unnoticed, causing confusing errors later when
project creation needed a team.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (event) Add 'sentry event list' command for issue-scoped event listing by BYK in #671
  • (init) Add detect-sentry local-op for cross-language Sentry detection by betegon in #657
  • (issue) Add sentry issue events command (feat: add sentry issue events command to list events for an issue #632) by BYK in #654
  • (period) Support absolute date ranges in --period flag by BYK in #674

Bug Fixes 🐛

Init

  • Run commands without shell to eliminate injection surface by betegon in #665
  • Use opendir for listDir and validate symlinks during traversal by betegon in #663
  • Rename 'Custom Metrics' feature label to 'Metrics' by MathurAditya724 in #659
  • Add reactFeatures to feature display info by MathurAditya724 in #658
  • Generate spinner messages from payload params instead of server detail by MathurAditya724 in #655

Other

  • (errors) Separate informational notes from actionable alternatives in ContextError by BYK in #651
  • (skill-gen) Eliminate manual maps to prevent undocumented commands by BYK in #670
  • Three bug fixes from Sentry telemetry (CLI-SC, CLI-QZ, CLI-WD) by cursor in #664
  • Fix set-commits --auto, document release workflow pitfalls by BYK in #650

Internal Changes 🔧

Init

  • Reuse resolveOrCreateTeam for wizard team resolution by betegon in #679
  • Route wizard errors through framework error pipeline by betegon in #678
  • Use guardNonInteractive for TTY check by betegon in #677
  • Use shared DRY_RUN_FLAG and add -n alias by betegon in #676
  • Reuse resolveOrg for offline-first org detection by betegon in #666
  • Use mdKvTable and renderMarkdown for wizard summary by betegon in #661

Other

  • Extract createProjectWithDsn to deduplicate project creation by betegon in #667
  • Regenerate skill files and command docs by github-actions[bot] in eb1b19e7

Other

  • Update custom.css by stevenplewis in #653

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Codecov Results 📊

134 passed | Total: 134 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 1460 uncovered lines.
❌ Project coverage is 95.5%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    95.51%    95.50%    -0.01%
==========================================
  Files          223       223         —
  Lines        32424     32425        +1
  Branches         0         0         —
==========================================
+ Hits         30968     30965        -3
- Misses        1456      1460        +4
- Partials         0         0         —

Generated by Codecov Action

@betegon betegon marked this pull request as ready for review April 7, 2026 11:44
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 67f963c. Configure here.

WizardError defaults rendered=true, so the framework error handler
suppresses output. Every other throw site calls log.error() + cancel()
first to display the message. The new catch block was missing this,
which would silently swallow the error.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@betegon betegon merged commit 6f46e16 into main Apr 7, 2026
26 checks passed
@betegon betegon deleted the refactor/init-reuse-resolve-team branch April 7, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant